package com.imooc.dto;

import java.util.Date;

import javax.validation.constraints.Past;

import org.hibernate.validator.constraints.NotBlank;

import com.fasterxml.jackson.annotation.JsonView;
import com.imooc.validator.MyConstraint;

public class User {
	
	/*
	 * 1.声明两个视图接口
	 */
	public interface UserSimpleView{};
	public interface UserDetialView extends UserSimpleView{};
	
	@MyConstraint(message = "我的自定义校验器")
	private String username;
	
	@NotBlank(message = "密码不能为空")
	private String password;
	
	private String id;
	
	@Past(message = "生日必须为过去的时间")
	private Date birthday;

	@JsonView(UserSimpleView.class)
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public User() {
	}
	/*
	 * 2.在值对象的get方法上指定视图
	 */
	@JsonView(UserSimpleView.class)
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	@JsonView(UserDetialView.class)
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@JsonView(UserSimpleView.class)
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public User(String username, String password) {
		super();
		this.username = username;
		this.password = password;
	}
}
